package cn.wfu.rlrjds.app.repaire.dao.ipml;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.wfu.rlrjds.app.bean.Count;
import cn.wfu.rlrjds.app.bean.RepaireSearch;
import cn.wfu.rlrjds.app.repaire.dao.IRepaireDao;
import cn.wfu.rlrjds.app.repaire.domain.Repaire;
import cn.wfu.rlrjds.app.repairman.domain.Repaireman;
import cn.wfu.rlrjds.app.user.domain.User;
import cn.wfu.rlrjds.common.dao.impl.MybatisDaoImpl;

@Repository
public class RepaireDaoIpml extends MybatisDaoImpl<Repaire, String> implements
		IRepaireDao {

	/**
	 * 修改提交订单用户的姓名
	 */
	@Override
	public void updateRepaireName(User user) {
		// TODO Auto-generated method stub
		this.update(SQL_UPDATEREPAIRENAME, user);

	}

	/**
	 * 添加评价
	 */
	@Override
	public void addEvaluate(Map<String, String> map) {
		// TODO Auto-generated method stub
		// 增加对维修员的评价
		this.update(SQL_ADDEVALUATE, map);
	}

	/**
	 * 修改订单的确认状态
	 */
	public void updateConfirmStatus(Map<String, String> map) {
		this.update(SQL_UPDATECONFIRMSTATUS, map.get("rid"));
	}

	/**
	 * 获取未维修的订单
	 */
	@Override
	public List<Repaire> getAllRepaireByRepaireStatus() {
		// TODO Auto-generated method stub
		return selectList(SQL_GETALLREPAIREBYREPAIRESTATUS);
	}

	/**
	 * 修改维修记录的维修状态
	 */
	@Override
	public void updateRepairStatus(Repaire repaire) {
		// TODO Auto-generated method stub
		update(SQL_UPDATEREPAIRSTATUS, repaire);
	}

	/**
	 * 查找符合条件的订单
	 */
	@Override
	public List<Repaire> list(RepaireSearch repaireSearch) {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_LIST, repaireSearch);
	}

	/**
	 * 通过学院查找各学院报修的数量
	 */
	@Override
	public List<Count> findCountGroupByCollege() {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_FINDCOUNTGROUPBYCOLLEGE);
	}

	/**
	 * 通过报修的主类型查找数量
	 */
	@Override
	public List<Integer> findTypeCount() {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_FINDTYPECOUNT);
	}

	@Override
	public List<Integer> findApartmentGoodsCount() {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_FINDAPARTMENTGOODSCOUNT);
	}

	@Override
	public List<Integer> findApartmentNetCount() {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_FINDAPARTMENTNETCOUNT);
	}

	@Override
	public List<Integer> findSchoolGoodsCount() {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectList(SQL_FINDSCHOOLGOODSCOUNT);
	}

	@Override
	public void updateIsdeleteByIds(String[] ids) {
		// TODO Auto-generated method stub
		this.getSqlSession().update(SQL_UPDATEISDELETEBYIDS, ids);
	}

}
